//
//  CustomTableViewCell.m
//  Demo0035
//
//  Created by zTercel on 13-4-7.
//  Copyright (c) 2013年 zTercel. All rights reserved.
//

#import "CustomTableViewCell.h"

@implementation CustomTableViewCell
enum {
    eNameTag = 3, ePhoneTag = 1
};
UILabel     *phoneValueLable;
UILabel     *nameValueLable;
@synthesize name;
@synthesize phone;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        CGRect nameKeyRect          = CGRectMake(0, 5, 70, 15);
        UILabel *nameKeyLable       = [[UILabel alloc]initWithFrame:nameKeyRect];
        nameKeyLable.text           = @"Name: ";
        nameKeyLable.font           = [UIFont boldSystemFontOfSize:15];
        nameKeyLable.textAlignment  = NSTextAlignmentRight;
        [self.contentView addSubview:nameKeyLable];
        
        CGRect phoneKeyRect         = {0, 25, 70, 15};
        UILabel *phoneKeyLable      = [[UILabel alloc]initWithFrame:phoneKeyRect];
        phoneKeyLable.text          = @"Phone: ";
        phoneKeyLable.font          = [UIFont boldSystemFontOfSize:15];
        phoneKeyLable.textAlignment = NSTextAlignmentRight;
        [self.contentView addSubview:phoneKeyLable];

        CGRect nameValueRect        = CGRectMake(80, 5, 200, 15);
        nameValueLable              = [[UILabel alloc]initWithFrame:nameValueRect];
        nameValueLable.textAlignment= NSTextAlignmentLeft;
        nameValueLable.tag          = eNameTag;
        nameValueLable.font         = [UIFont boldSystemFontOfSize:14];
        [self.contentView addSubview:nameValueLable];
       
        CGRect phoneValueRect       = CGRectMake(80, 25, 200, 15);
        phoneValueLable             = [[UILabel alloc]initWithFrame:phoneValueRect];
        phoneValueLable.tag         = ePhoneTag;
        phoneValueLable.font        = [UIFont boldSystemFontOfSize:14];
        [self.contentView addSubview:phoneValueLable];
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (void)setName:(NSString *)_name
{
    if (![_name isEqualToString:self.name])
    {
        name = [_name copy];
        nameValueLable.font         = [UIFont boldSystemFontOfSize:12];
        nameValueLable.text         = _name;
    }
    return;
}

- (void)setPhone:(NSString *)_phone
{
    if (![_phone isEqualToString: self.phone]) {
        phone = [_phone copy];
      //  phoneValueLable.text      = self.phone;  
        UILabel *phoneLable         = (UILabel*)[self.contentView viewWithTag:ePhoneTag];
        phoneLable.text             = self.phone;
      
    }
    return;
}


@end
